﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using XKJ.OAWeb.Application;
using XKJ.OAWeb.Models;

namespace XKJ.OAWeb.Api.Controllers
{
    /// <summary>
    /// 用户角色关系添加
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    //授权特性，表示：下面的所有方法都必须登录才能调用
    [Authorize]
    public class UserRoleController : ControllerBase
    {
        IUserRoleService _userRole;

        public UserRoleController(IUserRoleService userRole)
        {
            _userRole = userRole;
        }
        /// <summary>
        /// 用户角色关系添加
        /// </summary>
        /// <param name="userRole"></param>
        /// <returns></returns>
        [HttpPost]
        //允许匿名访问的特性
        [AllowAnonymous]
        public IActionResult UserRoleAdd(UserRole userRole)
        {
            return Ok(_userRole.UserRoleAdd(userRole));
        }
        /// <summary>
        /// 用户角色关系显示
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        //允许匿名访问的特性
        [AllowAnonymous]
        public IActionResult UserRoleShow(int Id)
        {
            return Ok(_userRole.UserRoleShow(Id));
        }
    }
}
